package com.android.RssReader;



import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import android.app.Application;
import android.content.SharedPreferences;
import android.graphics.drawable.Drawable;
import android.preference.PreferenceManager;
import android.util.Log;

import com.android.RssReader.Model.NewsInfoBean;

public class RssReaderApplication extends Application{
	private static RssReaderApplication instance;
	private HashMap<String, SoftReference<Drawable>> imageCache;
	private final static String TAG = "RssReader";
	public static final String XML_NAME = "NewsCategory";
	public static final String NEWS_CATEGORY_DEFAULT1_NAME = "焦点";
	public static final String NEWS_CATEGORY_DEFAULT1_URL = "http://news.baidu.com/n?cmd=1&class=civilnews&tn=rss";
	public static final String NEWS_CATEGORY_DEFAULT2_NAME = "国内";
	public static final String NEWS_CATEGORY_DEFAULT2_URL = "http://news.163.com/special/00011K6L/rss_gn.xml";
	public static String mDownloadPath = "rss_update.apk";
	public List<NewsInfoBean> listNewsCache = null;
	SharedPreferences preferences ;
	String serverIp, serverPort;
	int fontSize, deleteHistory;

	public static RssReaderApplication getInstance() {
		return instance;
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		instance = this;
		listNewsCache = new ArrayList<NewsInfoBean>();
		imageCache = new HashMap<String, SoftReference<Drawable>>();
		preferences = PreferenceManager.getDefaultSharedPreferences(this);
		serverIp = preferences.getString("server_ip_edit", "potank.xicp.net");
		serverPort = preferences.getString("server_port_edit", "5222");
		fontSize = preferences.getInt("font_size_value", 2);
		deleteHistory = preferences.getInt("delete_history_value", 2);
		LogD(this.getClass(),"serverIp:" + serverIp);
		LogD(this.getClass(),"serverPort:" + serverPort);
		LogD(this.getClass(),"fontSize:" + fontSize);
		LogD(this.getClass(),"deleteHistory:" + deleteHistory);
	}
	
	@SuppressWarnings("rawtypes")
	public static void LogD(Class classz, String str){
		Log.d(TAG, classz.getCanonicalName() + "--->" + str);
	}

	
	public HashMap<String, SoftReference<Drawable>> getImageCache() {
		return imageCache;
	}
	
}
